package com.tanglongan.designPattern.dp14_command.demo01;

import java.util.ArrayList;
import java.util.List;

public class Controller {

    private final List<IAction> actions = new ArrayList<>();

    public void addAction(IAction action) {
        actions.add(action);
    }

    /**
     * 执行单个命令
     */
    public void execute(IAction action) {
        action.execute();
    }

    /**
     * 执行多个命令
     */
    public void executes() {
        for (IAction action : actions) {
            action.execute();
        }
        actions.clear();
    }

}
